package icasue.net.socket.utils;

import java.util.concurrent.*;

/**
 * @Author: Qiao Hang
 * @CreateDate: 2021/3/18 下午4:43
 * @UpdateDate:
 * @Description:
 */
public class PoolUtil {

    /*ThreadPool required supplied by developer.*/
    /*private static ThreadPoolExecutor pool = new ThreadPoolExecutor(
            10,
            100,
            10,TimeUnit.MINUTES,
            new LinkedBlockingQueue<>()
    );*/
    private static ThreadPoolExecutor pool = null;

    public static void execute(Runnable runner){
        pool.execute(runner);
    }

    public static Future submit(Runnable task){
        Future<?> future = pool.submit(task);
        return future;
    }

    public static <T> Future<T> submit(Runnable task,T result){
        Future<T> future = pool.submit(task,result);
        return future;
    }

    public static <T> Future<T> submit(Callable<T> task){
        Future<T> future = pool.submit(task);
        return future;
    }
}
